package com.fay.basic.collection.map;

import java.util.HashMap;

/**
 * @Title:
 * @Description:
 * @Author Fay Wang
 * @Date 2022/5/10 16:47
 * @Version 1.0
 */
public class HashMapTest {
    public static void main(String[] args) {
        HashMap<A, Integer> mapA = new HashMap<>();
        mapA.put(new A(), 10);
        mapA.put(new A(), 5);
        System.out.println("MapA Elements:");
        System.out.print("\t" + mapA + "\n");

        HashMap<B, Integer> mapB = new HashMap<>();
        mapB.put(new B(), 10);
        mapB.put(new B(), 5);
        System.out.println("MapB Elements:");
        System.out.print("\t" + mapB + "\n");

        HashMap<C, Integer> mapC = new HashMap<>();
        mapC.put(new C(), 10);
        mapC.put(new C(), 5);
        System.out.println("HashMapC Elements:");
        System.out.print("\t" + mapC + "\n");

        HashMap<D, Integer> mapD = new HashMap<>();
        mapD.put(new D(), 10);
        mapD.put(new D(), 5);
        System.out.println("HashMapD Elements:");
        System.out.print("\t" + mapD + "\n");
    }
}

class A {
    @Override
    public boolean equals(Object obj) {
        return true;
    }
}

class B {
    @Override
    public int hashCode() {
        return 1;
    }
}

class C {
    @Override
    public int hashCode() {
        return 2;
    }

    @Override
    public boolean equals(Object obj) {
        return true;
    }
}

class D {

}
